<?php
	
	/**
	 * @see Zend_Controller_Dispatcher_Standard
	 */
	require_once 'Zend/Controller/Dispatcher/Standard.php';
	
	
	class Bike_Controller_Dispatcher extends Zend_Controller_Dispatcher_Standard
	{
	     static protected $_modulePrefix = 'Bike_Module_';
	
	     protected $_wordDelimiter = array('-');
	
	     static public function getModulePrefix()
	     {
	     	return self::$_modulePrefix;
	     }
	
	     static public function setModulePrefix($ModulePrefix)
	     {
	     	self::$_modulePrefix = $ModulePrefix;
	     }
	
		/**
	     * Formats a string into a controller name.  This is used to take a raw
	     * controller name, such as one stored inside a Zend_Controller_Request_Abstract
	     * object, and reformat it to a proper class name that a class extending
	     * Zend_Controller_Action would use.
	     *
	     * @param string $unformatted
	     * @return string
	     */
	    public function formatControllerName($unformatted)
	    {
	        return 'Controller_'.ucfirst($this->_formatName($unformatted));
	    }
	
	    /**
	     * Format the module name.
	     *
	     * @param string $unformatted
	     * @return string
	     */
	    public function formatModuleName($unformatted)
	    {
	        if (($this->_defaultModule == $unformatted) && !$this->getParam('prefixDefaultModule')) {
	            return $unformatted;
	        }
	
	        return $this->getModulePrefix().ucfirst($this->_formatName($unformatted));
	    }
	
	    /**
	     * Format action class name
	     *
	     * @param string $moduleName Name of the current module
	     * @param string $className Name of the action class
	     * @return string Formatted class name
	     */
	    public function formatClassName($moduleName, $className)
	    {
	        return $this->formatModuleName($moduleName) . '_' . $className;
	    }
	
	    /**
	     * Convert a class name to a filename
	     *
	     * @param string $class
	     * @return string
	     */
	    public function classToFilename($class)
	    {
	        return str_replace(array('Controller_','_'), array('', DIRECTORY_SEPARATOR), $class) . '.php';
	    }
	
	
	    /**
	     * Formats a string into an action name.  This is used to take a raw
	     * action name, such as one that would be stored inside a Zend_Controller_Request_Abstract
	     * object, and reformat into a proper method name that would be found
	     * inside a class extending Zend_Controller_Action.
	     *
	     * @param string $unformatted
	     * @return string
	     */
	    public function formatActionName($unformatted)
	    {
	        $formatted = $this->_formatName($unformatted, true);
	        return 'action'.ucfirst($this->getArea()->getArea()).$formatted;
	    }
	
	    protected function getArea()
	    {
	    	return Bike_Area::getInstance();
	    }
	}
